using ASP;
using HoWave.Web.Shop.Member;
using System;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
public class Shop_Member_Shop_SendOrderView : Member, IRequiresSessionState
{
	private string StrWhere = "";
	protected ScriptManager ScriptManager1;
	protected TextBox TxtHanderName;
	protected TextBox TxtUserName;
	protected TextBox TxtBeginDate;
	protected TextBox TxtEndDate;
	protected Button QuickSearchBtn;
	protected TextBox OrderFormBox;
	protected DropDownList DropDeliverType;
	protected GridView GridView3;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		this.TxtBeginDate.Attributes.Add("onclick", "SelectDate(" + this.TxtBeginDate.UniqueID + ",'yyyy-MM-dd');");
		this.TxtEndDate.Attributes.Add("onclick", "SelectDate(" + this.TxtEndDate.UniqueID + ",'yyyy-MM-dd');");
		if (!base.IsPostBack)
		{
			this.DataBindDeliverItem();
		}
	}
	protected void GridView3_DataBound(object sender, EventArgs e)
	{
		foreach (GridViewRow gridViewRow in this.GridView3.Rows)
		{
			if (gridViewRow.Cells[0].Text != "")
			{
				gridViewRow.Cells[0].Text = DateTime.Parse(gridViewRow.Cells[0].Text).ToShortDateString();
			}
			if (gridViewRow.Cells[1].Text.Trim() == "0")
			{
				gridViewRow.Cells[1].Text = "发货";
			}
			if (gridViewRow.Cells[1].Text.Trim() == "1")
			{
				gridViewRow.Cells[1].Text = "退货";
			}
		}
	}
	public void StrWhereQuery()
	{
		if (this.TxtHanderName.Text != "")
		{
			this.StrWhere = " and HandlerName like '%" + this.TxtHanderName.Text + "%'";
		}
		if (this.TxtUserName.Text != "")
		{
			this.StrWhere = " and HL_User.UserName like '%" + this.TxtUserName.Text + "%'";
		}
		if (this.TxtBeginDate.Text.Length > 1)
		{
			this.StrWhere = " and DeliverDate>='" + this.TxtBeginDate.Text + "'";
		}
		if (this.TxtEndDate.Text.Length > 1)
		{
			this.StrWhere = " and DeliverDate<='" + this.TxtEndDate.Text + "'";
		}
		if (!string.IsNullOrEmpty(this.OrderFormBox.Text))
		{
			this.StrWhere = " and hlshop_order.OrderFormNum='" + this.OrderFormBox.Text + "'";
		}
		string selectedValue = this.DropDeliverType.SelectedValue;
		if (selectedValue != null)
		{
			if (!(selectedValue == "0"))
			{
				if (selectedValue == "1")
				{
					this.StrWhere = " and DeliverType=1 ";
				}
			}
			else
			{
				this.StrWhere = " and DeliverType=0 ";
			}
		}
	}
	public void DataBindDeliverItem()
	{
		this.StrWhereQuery();
		string sql = string.Concat(new object[]
		{
			"SELECT HLShop_DeliverItem.*, HL_User.UserName, HLShop_Order.OrderFormNum, HLShop_Order.ContacterName FROM HLShop_DeliverItem INNER JOIN HL_User ON HLShop_DeliverItem.UserID = HL_User.UserID INNER JOIN HLShop_Order ON HLShop_DeliverItem.OrderID = HLShop_Order.OrderFormID ",
			this.StrWhere,
			" and  HLShop_DeliverItem.Inputer=",
			base.user.UserID,
			"   Order by HLShop_DeliverItem.DeliverID desc"
		});
		this.GridView3.DataSource = this.conn.GetDataSet(sql);
		this.GridView3.DataBind();
	}
	public string ShowFatReturnStatus(string DeliverType)
	{
		string result;
		if (DeliverType == "0")
		{
			result = "发货";
		}
		else
		{
			result = "退货";
		}
		return result;
	}
	protected void DropDeliverType_SelectedIndexChanged(object sender, EventArgs e)
	{
		this.DataBindDeliverItem();
	}
	protected void QuickSearchBtn_Click(object sender, EventArgs e)
	{
		this.DataBindDeliverItem();
	}
	protected void GridView3_PageIndexChanging(object sender, GridViewPageEventArgs e)
	{
		this.GridView3.PageIndex = e.NewPageIndex;
		this.DataBindDeliverItem();
	}
}
